package com.yfj.web;

import java.util.List;

import com.yfj.entity.Student;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yfj.entity.Course;
import com.yfj.service.TeacherService;

@Controller
public class TeacherController {
	
	@Autowired
	TeacherService teacherService;

	@RequiresRoles("teacher")
	@RequestMapping({"/teacher","/teaAllCourse"})
	public String teaAllCourse() {
		return "teacher/teaAllCourse";
	}
	@RequiresRoles("teacher")
	@RequestMapping("/teaCourseList")
	public String teaCourseList() {
		return "teacher/teaCourseList";
	}
	
	/**
	 * 获得该教师教授 的所有课程
	 * @return
	 */
	@RequiresRoles("teacher")
	@RequestMapping({"/getTeaAllCourse","/getTeaCourseTable"})
	@ResponseBody
	public List<Course> getTeaAllCourse(Long teaId){
		List<Course> cList=teacherService.getCourseList(teaId);
		return cList;
	}

	//跳转查询学生页面
	@RequestMapping("/queryStudent")
	public String queryStudent(){
		return "teacher/queryStudent";
	}

	//查询某课程下的学生
	@RequestMapping("/queryStudentByCourseID")
	@ResponseBody
	public List<Student> queryStudentByCourseID(Long courseId){
		List<Student> studentList = teacherService.getStudentList(courseId);
		return studentList;
	}
}
